public class Leetcoed537 {
    public static void main(String[] args) {
        System.out.println(complexNumberMultiply("1+-1i", "1+-1i"));
    }

    public static String complexNumberMultiply(String num1, String num2) {
        String[] str1 = num1.split("\\+");
        String[] str2 = num2.split("\\+");
        int num1Start = Integer.parseInt(str1[0]);
        int num2Start = Integer.parseInt(str2[0]);
        int num1End = Integer.parseInt(str1[1].substring(0, str1[1].length() - 1));
        int num2End = Integer.parseInt(str2[1].substring(0, str2[1].length() - 1));

        return new StringBuilder(String.valueOf((num1Start * num2Start) + (num1End * num2End * -1))).append("+").append((num1Start * num2End) + (num1End * num2Start)).append("i").toString();
    }
}
